<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="${basePath }"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="3rd/ligerui/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css"/>
    <script src="3rd/ligerui/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="3rd/ligerui/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
    <script charset="utf-8" src="3rd/kindeditor-4.1.1/kindeditor-min.js"></script>
    <script charset="utf-8" src="3rd/kindeditor-4.1.1/lang/zh_CN.js"></script>
    <script type="text/javascript" src="3rd/jscolor/jscolor.js"></script>
    <script src="3rd/ligerui/jquery-validation/jquery.validate.min.js" type="text/javascript"></script>
    <script src="3rd/ligerui/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
    <script src="3rd/ligerui/jquery-validation/messages_cn.js" type="text/javascript"></script>
    <script type="text/javascript">
        var openWin,editor;


        $(function () {

            //创建表单结构
            $("#publist").ligerDateEditor({ showTime: true});
            $("form").ligerForm();
            editor = KindEditor.create('textarea[name="content"]');
            $('#selectArt').click(function() {
                openWin = $.ligerDialog.open({ url: '${basePath }text/list.shtml', height: 500,width: 800 });
            });

            $.metadata.setType("attr", "validate");
            $("form").validate({
                errorPlacement: function (lable, element) {
                    if (element.hasClass("l-textarea")) {
                        element.ligerTip({ content: lable.html(), target: element[0] });
                    }
                    else if (element.hasClass("l-text-field")) {
                        element.parent().ligerTip({ content: lable.html(), target: element[0] });
                    }
                    else {
                        lable.appendTo(element.parents("td:first").next("td"));
                    }
                },
                success: function (lable) {
                    lable.ligerHideTip();
                    lable.remove();
                },
                submitHandler: function () {
                    $('#textContent').val(editor.text());
                    $("form .l-text,.l-textarea").ligerHideTip();
                    document.form1.submit();
                }
            });
        });

        function getSel(rows) {
            for (var i in rows) {
                $('#selSpan').append('<input name="artids" type="checkbox" checked="checked" value="' + rows[i].id + '" />' + rows[i].title);
                openWin.close();
            }
        }

    </script>
</head>
<body style="padding: 10px">
<form method="post" name="form1" action="text/save.shtml">
    <table id="formTable" cellpadding="0" cellspacing="0" class="l-table-edit">
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">文章所属模型:&nbsp;</td>
            <td align="left" class="l-table-edit-td">
                文章模型
                <input type="hidden" value="A" name="type"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">类别:</td>
            <td align="left" class="l-table-edit-td">
                <c:forEach items="${categories}" var="entry">
                    <input value="${entry.key}" name="category" type="checkbox"/>${entry.value}
                </c:forEach>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">推荐位:</td>
            <td align="left" class="l-table-edit-td">
                <c:forEach items="${recommends}" var="entry">
                    <input value="${entry.key}" name="recommend" type="checkbox"/>${entry.value}
                </c:forEach>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">栏目:</td>
            <td align="left" class="l-table-edit-td">
                <select name="part">
                    <option value="">请选择</option>
                    <c:forEach items="${parts}" var="entry">
                        <option value="${entry.key}"
                                <c:if test="${entry.key eq data.part}">selected="selected" </c:if> >${entry.value}</option>
                    </c:forEach>
                </select>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">文章排序:</td>
            <td align="left" class="l-table-edit-td">
                <input name="sort" validate="{digits:true,min:0}" value="${data.sort}"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">标题:</td>
            <td align="left" class="l-table-edit-td">
                <input name="title" validate="{required:true}" value="${data.title}"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">简略标题:</td>
            <td align="left" class="l-table-edit-td">
                <input name="brieftitle" value="${data.brieftitle}"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">标题颜色:</td>
            <td align="left" class="l-table-edit-td">
                <input class="color" value="${data.titlecolor}" name="titlecolor"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">加粗:</td>
            <td align="left" class="l-table-edit-td">
                <input name="titlestyle" type="checkbox"
                       <c:if test="${data.titlestyle=='bold'}">checked="checked"</c:if> value="bold"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">作者:</td>
            <td align="left" class="l-table-edit-td">
                <input name="author" value="${data.author}" validate="{required:true}"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">来源:</td>
            <td align="left" class="l-table-edit-td">
                <input name="source" value="${data.source}" validate="{required:true}"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">跳转网址:</td>
            <td align="left" class="l-table-edit-td">
                <input name="clickgourl" value="${data.clickgourl}"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">相关文章:</td>
            <td align="left" class="l-table-edit-td">
                <a href="javascript:void(0)" id="selectArt">选择</a>
                <span id="selSpan"></span>
            </td>
        </tr>
        <tr>
            <td align="right" class="l-table-edit-td">摘要 :</td>
            <td align="left" class="l-table-edit-td">
                <textarea cols="100" rows="4" class="l-textarea" id="summary" name="summary"
                          style="width:400px">${data.summary}</textarea>
            </td>
            <td align="left"></td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">是否生成摘要:</td>
            <td align="left" class="l-table-edit-td">
                <input type="checkbox" value="Y" name="briefflag"
                       <c:if test="${data.briefflag=='Y'}">checked="checked"</c:if> >
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">发布时间:</td>
            <td align="left" class="l-table-edit-td">
                <input type="text" name="publist" id="publist" readonly="readonly" value="${data.publist}"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">关键词:</td>
            <td align="left" class="l-table-edit-td">
                <input type="text" name="keyword" value="${data.keyword}"/>
            </td>
        </tr>
        <tr style="line-height: 30px;">
            <td align="right" class="l-table-edit-td">内容:</td>
            <td align="left" class="l-table-edit-td">
                <textarea style="width:700px;height:400px;visibility:hidden;" id='content'
                          name="content">${data.content}</textarea>
                <input type="hidden" name="textContent" id="textContent"/>
            </td>
        </tr>

        <tr style="line-height: 30px;">
            <td class="l-table-edit-td"><input type="submit" value="保存" class="l-button l-button-submit"/></td>
        </tr>
    </table>
</form>
</body>
</html>